home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Views / Frame.cp next >
Text File  |  1997-06-28  |  3KB  |  131 lines

  1. // Frame.cp
  2.  
  3. #ifndef Frame_h
  4. #include "Frame.h"
  5. #endif
  6. #ifndef ViewMap_h
  7. #include "ViewMap.h"
  8. #endif
  9.  
  10. void Frame::Draw( const ViewMap& map ) const
  11.   {
  12.     Rectangle inside( map.Bounds() );
  13.     inside.Inset( thickness );
  14.     DrawBorder( map, inside );
  15.     
  16.     ViewMap interiorMap( map );
  17.     interiorMap.Set( map, inside );
  18.     
  19.     if ( interiorMap.Visible() )
  20.         interior->Draw( interiorMap );
  21.   }
  22.  
  23. void Frame::GainMapping()
  24.   {
  25.     Rectangle inside( Owner().Bounds() );
  26.     inside.Inset( thickness );
  27.     interior.SetBounds( inside );
  28.     interior.MapTo( Owner().Window() );
  29.   }
  30.  
  31. void Frame::LoseMapping()
  32.   {
  33.     interior.Unmap();
  34.   }
  35.  
  36. void Frame::ChangeBounds( Rectangle )
  37.   {
  38.     if ( Mapped() )
  39.       {
  40.         Rectangle inside( Owner().Bounds() );
  41.         inside.Inset( thickness );
  42.         interior.SetBounds( inside );
  43.       }
  44.   }
  45.  
  46. uint16 Frame::MinimumWidth() const
  47.   {
  48.     uint16 width = interior->MinimumWidth();
  49.     return ( width < maxint16 - thickness.Width() )
  50.                 ? width + thickness.Width()
  51.                 : maxint16;
  52.   }
  53.  
  54. uint16 Frame:: MinimumHeight() const
  55.   {
  56.     uint16 height = interior->MinimumHeight();
  57.     return ( height < maxint16 - thickness.Height() )
  58.                 ? height + thickness.Height()
  59.                 : maxint16;
  60.   }
  61.  
  62. uint16 Frame:: MaximumWidth() const
  63.   {
  64.     uint16 width = interior->MaximumWidth();
  65.     return ( width < maxint16 - thickness.Width() )
  66.                 ? width + thickness.Width()
  67.                 : maxint16;
  68.   }
  69.  
  70. uint16 Frame:: MaximumHeight() const
  71.   {
  72.     uint16 height = interior->MaximumHeight();
  73.     return ( height < maxint16 - thickness.Height() )
  74.                 ? height + thickness.Height()
  75.                 : maxint16;
  76.   }
  77.  
  78. uint16 Frame:: ReasonableWidth() const
  79.   {
  80.     uint16 width = interior->ReasonableWidth();
  81.     return ( width < maxint16 - thickness.Width() )
  82.                 ? width + thickness.Width()
  83.                 : maxint16;
  84.   }
  85.  
  86. uint16 Frame:: ReasonableHeight() const
  87.   {
  88.     uint16 height = interior->ReasonableHeight();
  89.     return ( height < maxint16 - thickness.Height() )
  90.                 ? height + thickness.Height()
  91.                 : maxint16;
  92.   }
  93.  
  94. uint16 Frame:: BestWidth() const
  95.   {
  96.     uint16 width = interior->BestWidth();
  97.     return ( width < maxint16 - thickness.Width() )
  98.                 ? width + thickness.Width()
  99.                 : maxint16;
  100.   }
  101.  
  102. uint16 Frame:: BestHeight() const
  103.   {
  104.     uint16 height = interior->BestHeight();
  105.     return ( height < maxint16 - thickness.Height() )
  106.                 ? height + thickness.Height()
  107.                 : maxint16;
  108.   }
  109.  
  110. uint16 Frame::BestWidth( uint16 bound ) const
  111.   {
  112.     if ( bound < thickness.Width() )
  113.         return bound;
  114.     
  115.     uint16 width = interior->BestWidth( bound - thickness.Width() );
  116.     return ( width < maxint16 - thickness.Width() )
  117.                 ? width + thickness.Width()
  118.                 : maxint16;
  119.   }
  120.  
  121. uint16 Frame::BestHeight( uint16 bound ) const
  122.   {
  123.     if ( bound < thickness.Height() )
  124.         return bound;
  125.     
  126.     uint16 width = interior->BestHeight( bound - thickness.Height() );
  127.     return ( width < maxint16 - thickness.Height() )
  128.                 ? width + thickness.Height()
  129.                 : maxint16;
  130.   }
  131.